<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<link rel="stylesheet" href="${pageContext.request.contextPath }/css/editTablestyles.css" />
<script type="text/javascript" src="${pageContext.request.contextPath }/webjars/jquery/1.12.4/jquery.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/js/listTable.js"></script>
<script type="text/javascript">
	$(function(){
		$("#update").click(function(){
			var plateNumber = $("input[name='plateNumber']").val();
			var number = /(^[\u4E00-\u9FA5]{1}[A-Z0-9]{6}$)|(^[A-Z]{2}[A-Z0-9]{2}[A-Z0-9\u4E00-\u9FA5]{1}[A-Z0-9]{4}$)|(^[\u4E00-\u9FA5]{1}[A-Z0-9]{5}[挂学警军港澳]{1}$)|(^[A-Z]{2}[0-9]{5}$)|(^(08|38){1}[A-Z0-9]{4}[A-Z0-9挂学警军港澳]{1}$)/;
			if(plateNumber!=""){
				if(!number.test(plateNumber)){
					$("#resultPlateNumber").html("请输入正确的车牌号");
					return ;
				}
			}
			var displacement = $("input[name='displacement']").val();
			var cc = /^\d*\.{0,1}\d{0,1}\T|L$/;
			if(!cc.test(displacement)){
				$("#resultDisplacement").html("请输入正确格式必须以L或T结尾");
				return ;
			}
			var pattern = /^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2})$/;
		 	var date = $("input[name='date']").val();
			if(!pattern.test(date)){
				$("#resultDate").html("请输入正确的日期");
				return ;
			}			
			$("form").submit();
		});
	});
</script>
</head>
<body>
 	<form action="vehicle.action?methodName=doUpdateVehicle" method="post">
 		<table class="querytable" width="50%" style="margin-top:80px;" align="center">
 			<tr>
 				<th colspan="3" align="center">新增车辆信息列表</th>
 			</tr>
 			<tr>
 				<td class="textright">车辆型号：</td>
 				<td class="textleft">
 					<input type="text" name="vehicleTypeId" class="inputtext" value="${vehicle.vehicleTypeId }" />
 					<input type="hidden" name="vehicleId" value="${vehicle.vehicleId }" />
 				</td>
 				<td></td>
 			</tr>
 			<tr>
 				<td class="textright">车牌号：</td>
 				<td class="textleft">
 					<input type="text" name="plateNumber" class="inputtext" value="${vehicle.plateNumber }"/>
 				</td>
 				<td id="resultPlateNumber"></td>
 			</tr>
 			<tr>
 				<td class="textright">排量：</td>
 				<td class="textleft">
 					<input type="text" name="displacement" class="inputtext" value="${vehicle.displacement }" />
 				</td>
 				<td id = "resultDisplacement"></td>
 			</tr>
 			<tr>
 				<td class="textright">出厂日期：</td>
 				<td class="textleft">
 					<input type="text" name="date" class="inputtext"  value="${vehicle.date }"/>
 				</td>
 				<td id = "resultDate"></td>
 			</tr>
			<tr>
				<td colspan="3" align="center">
					<input type="button" value="修改" id="update" />
					<input type="button" value="返回" onclick="window.location='vehicle.action?methodName=doListVehicle&delete=${update}'" />
				</td>
			</tr>
 		</table>
 	</form>
</body>
</html>